package com.hmall.user.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hmall.user.Utils.ThreadLocalUtil;
import com.hmall.user.dao.UserDao;
import com.hmall.user.pojo.Address;
import com.hmall.user.service.UserService;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class UserServiceImpl extends ServiceImpl<UserDao,Address> implements UserService {
    @Autowired
    private UserDao userDao;
    @Override
    public List<Address> userUid() {
        //获取登陆的id
        Long id = ThreadLocalUtil.getUserId();
        LambdaQueryWrapper<Address> wapper = new LambdaQueryWrapper<>();
        wapper.eq(Address::getUserId,id);
//        LambdaQueryWrapper<Address> warrper = Wrappers.lambdaQuery(
//        );
//        warrper.eq(Address::getUserId,id);
        List<Address> userAddress = userDao.selectList(wapper);
        return userAddress;
    }

    @Override
    public Address address(Long id) {
        Address add = userDao.selectById(id);
        return add;
    }
}
